javascript中用<c:redirct...>

来源:百度知道 编辑:UC知道 时间:2024/06/17 13:28:52
JSP文件中,添加如下代码,明明都if(0)了,请问为什么总会跳转到baidu页面呢?
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
....
<head>
<script language="javascript">
if(0)
{
document.getElementById("go").innerHTML='<c:redirect url="http://www.baidu.com"/>';
}
else
{
document.getElementById("go").innerHTML='cat';
}
</script>
</head>
<body id="go">

</body>
</html:html>

window.location.href = "www.baidu.com";吧

<c:redirect 是c标签的跳转,在生成静态页面之前就会调用,当然会转到baidu

document.getElementById("go").innerHTML='<c:redirect url="http://www.baidu.com"/>';
改成:window.location.replace = "www.baidu.com";就可以了